<%--
  Created by IntelliJ IDEA.
  User: LMY
  Date: 2025/6/21
  Time: 21:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
      <title>计算结果</title>
  </head>

  <body>
    <h1>计算结果</h1>
  <%
    int num1 = Integer.parseInt(request.getParameter("num1"));
    int num2 = Integer.parseInt(request.getParameter("num2"));
    String symbol = request.getParameter("symbol");
    if (num2 == 0 && symbol.equals("/")) {
      %>
        计算错误，除数不能为0
      <%
      return;
    }
    int res;
    switch (symbol){
      case "+":
        res = num1 + num2;
        break;
      case "-":
        res = num1 - num2;
        break;
      case "*":
        res = num1 * num2;
        break;
      case "/":
        res = num1 / num2;
        break;
      default:
        res = 0;
        break;
    }
  %>
  <%=num1%> <%=symbol%> <%=num2%> = <%=res%><br/>
  <a href="cal.jsp">返回再来玩一次</a>
  </body>
</html>
